{include file=header.html}
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
<body>
    <div class="sub-body">
        <div class="tab-frame" style="width: 700px">
            <div class="tab-title-1"><span>报价公式</span></div>
            <table width="100%" cellspacing="0" cellpadding="0" class="tab-display">
                <tr>
                    <th width="20%">公式</th>
                    <td></td>
                </tr>
                <!--{foreach from=$calcs item=calc}-->
                <tr id="calc_tr_{$calc.id}">
                    <th>{$calc.name}</th>
                    <td align="left">请输入：<input type="text" id="input_{$calc.id}" class="input-1"/> <input type="button" onClick="calc_{$calc.id}($('#input_{$calc.id}').val(),'#result_{$calc.id}')" value="计算" class="btn-1"/><span id="result_{$calc.id}" style="padding:0 10px;"></span></td>
                </tr>
                <!--{/foreach}-->
            </table>
            <script>
                <!--{foreach from=$calcs item=calc}-->
                function calc_{$calc.id}(input,r){
                    <!--{foreach from=$calc.para item=p key=key}-->
                    var {$key}=parseFloat('{$p}');
                    <!--{/foreach}-->
                    input=parseFloat(input);
                    var result={$calc.gongshi};
                    //alert(result);
                    
                    $(r).html(FormatNumber(result,2));
                    return result;
                }
                <!--{/foreach}-->
                function FormatNumber(srcStr,nAfterDot)        //nAfterDot小数位数
                {
                    var srcStr,nAfterDot;
                    var resultStr,nTen;
                    srcStr = ""+srcStr+"";
                    strLen = srcStr.length;
                    dotPos = srcStr.indexOf(".",0);
                    if (dotPos == -1){
                        resultStr = srcStr+".";
                        for (i=0;i<nAfterDot;i++){
                            resultStr = resultStr+"0";
                        }
                        return resultStr;
                    }
                    else{
                        if ((strLen - dotPos - 1) >= nAfterDot){
                            nAfter = dotPos + nAfterDot + 1;
                            nTen =1;
                            for(j=0;j<nAfterDot;j++){
                                nTen = nTen*10;
                            }
                            resultStr = Math.round(parseFloat(srcStr)*nTen)/nTen;
                            return resultStr;
                        }
                        else{
                            resultStr = srcStr;
                            for (i=0;i<(nAfterDot - strLen + dotPos + 1);i++){
                                resultStr = resultStr+"0";
                            }
                            return resultStr;
                        }
                    }
                }
            </script>
            <script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
        </div>
    </div>
</body>
</html>